/*****************************************************************************
 *   Copyright 2005 Tim A Wang
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 *
 ****************************************************************************/
package com.jb.java.tools;


/**
 * Code geneator generates Java code.
 */
public abstract class AbstractCodeGenerator implements CodeGenerator {
    String className;
    String packageName;

    /**
    * Constructor
    * @param pPackageName
    * @param pClassName
    */
    public AbstractCodeGenerator(String packageName, String classname) {
        this.className = classname;
        this.packageName = packageName;
    }

    /**
    * Returns class name.
    * @return class name.
    */
    public String getClassName() {
        return className;
    }

    /**
    * Returns qualified name for generated code.
    * @return qName.
    */
    public String getClassQName() {
        if ((packageName != null) && (packageName.length() > 0)) {
            return packageName + "." + className;
        } else {
            return className;
        }
    }

    /**
    * Returns generated code as a string.
    * @return generated code.
    */
    public abstract String getCode();

    /**
    * Returns package name.
    * @return package name.
    */
    public String getPackageName() {
        return packageName;
    }

    /**
     * Returns a runner that can be used to execute the generated code.
     * @return runner, @see Runner.
     */
    public abstract Runner getRunner();
}
